/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entite;

import connexion.Connexion;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author asall
 */
public class Mention {
     static Connexion con= new Connexion();    
        
     public String getCodeMention(int idDiplome) {
		String res="code mention";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select men.code_apogee"
                                + " from diplome di,mention men "
                                + " where di.fid_men= men.id_men "
                                + " and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("code_apogee"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}     
    public String getLibelleMention(int idDiplome) {
		String res="libelle mention";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select men.libelle_mention"
                                + " from diplome di,mention men"
                                + " where di.fid_men= men.id_men"
                                + " and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("libelle_mention"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}     
    public String getCodeDom(int idDiplome) {
		String res="code domaine";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select do.code_apogee"
                                + " from diplome di,mention men, domaine do"
                                + " where di.fid_men= men.id_men and do.id_dom=men.fid_dom"
                                + " and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("code_apogee"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}     
    public String getLibelleDom(int idDiplome) {
		String res="libelle domaine";
		try {
			Statement req = con.getInstance().createStatement();

                        ResultSet resultatDest = req.executeQuery("select do.libelle_domaine"
                                + " from diplome di,mention men, domaine do"
                                + " where di.fid_men= men.id_men and do.id_dom=men.fid_dom"
                                + " and di.id_dip= "+ idDiplome );

			while (resultatDest.next()) {
				res=(resultatDest.getString("libelle_domaine"));
				return res;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return res;
	}     
}
